package com.chinatelecom.otms.circuitcheck.util;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FileUtil {
    public static CountDownLatch countDownLatch = null;
    public static final ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();

    public static String readStringListByFile(String fileName){
        try {
            FileReader fileReader = new FileReader(fileName);
            BufferedReader br = new BufferedReader(fileReader);
            String sncIdLine = br.readLine();
            fileReader.close();
            br.close();
            return sncIdLine;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static List<String> transformStringArgsToList(String[] circuit_string_args, int step) {
        //TODO
        return null;
    }

    public static void writeLine(String line, String fileName) throws IOException {
        File file = new File(fileName);
        if(! file.exists()){
            file.createNewFile();
        }
        FileWriter fileWriter = new FileWriter(fileName, true);
        fileWriter.write(line);
        fileWriter.close();
    }
}
